﻿<!--#include file="../lib/base.asp"-->
<!--#include file="../theme.asp"-->
<%
''' SDCMS 搜索
''' ==================================================================
''' 版权所有 http://www.sdcms.cn
''' ------------------------------------------------------------------
''' 这不是一个自由软件！您只能在不用于商业目的的前提下对程序代码进行修改和使用；
''' 未经授权不允许对程序代码以任何形式任何目的的再发布。
''' ==================================================================
''' 编写: IT平民
''' 修改：IT平民 in 2014.07

	dim sql_where:sql_where=""
	dim classid:classid=sdcms.getint(sdcms.fget("classid",0),0)
	dim key:key=sdcms.enhtml(sdcms.fget("key",0))
	dim keylen:keylen=sdcms.strlen(key)
	if keylen<=0  then
		dim errormsg:errormsg="&#20851;&#38190;&#23383;&#19981;&#33021;&#20026;&#31354;"
	end if
	if keylen<2 then
		errormsg="&#20851;&#38190;&#23383;&#19981;&#33021;&#23567;&#20110;&#50;&#20010;&#23383;&#31526;"
	end if
	if keylen>10  then
		errormsg="&#20851;&#38190;&#23383;&#19981;&#33021;&#22823;&#20110;&#49;&#48;&#20010;&#23383;&#31526;"
	end if
	
	if errormsg<>"" then
		sdcms.show theme_404,""
		sdcms.die
	end if
	
	if datatype then
		sql_where=sql_where&" and instr(1,lcase(title),lcase('"&key&"'),0)<>0"
	else
		sql_where=sql_where&" and title like '%"&key&"%'"
	end if
	if classid<>0 then
		sql_where=sql_where&"and classid in("&sdcms.get_sonid(classid)&")"
	end if
	sdcms.show theme_search,""
	if html_page_total<>0 and page=1 then
		addsearchkey key
	end if
	sdcms.db.dbclose
	
	sub addsearchkey(byval t0)
		if sdcms.loadcookie("search_keyword_"&t0)="" then
			dim rs
			set rs=server.createobject("adodb.recordset")
			rs.open "select title,hits,islock from sd_expand_keyword where title='"&t0&"'",sdcms.db.conn,1,3
			if rs.eof then
				rs.addnew
				rs(0)=t0
				rs(1)=1
				rs(2)=1
			else
				rs.update
				rs(1)=rs(1)+1
			end if
			rs.update
			rs.close
			set rs=nothing
			sdcms.setcookie "search_keyword_"&t0,t0
		end if
	end sub
%>